package com.fishingwithme.infrastructure.dtos.circle;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import com.fishingwithme.domain.common.Location;
import com.fishingwithme.infrastructure.utils.CommonUtils;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
public class CircleDetailDto {

    private Long id;
    private String title;
    private String description;
    private Double area;
    private Double latitude;
    private Double longitude;
    private List<Location> points;
    @JsonIgnore
    private String pointsString;
    @JsonIgnore
    private String picsString;
    private String city;
    private String cityCode;

    private List<String> pics;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createdAt;

    private Long createdBy;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updatedAt;

    private Long updatedBy;
    private Boolean isActive;

    public void formatPics() {
        if (this.pointsString != null) {
            this.points = CommonUtils.convert(this.pointsString, Location.class);
        }

        if (this.getPicsString() != null) {
            this.pics = CommonUtils.convert(this.picsString, String.class);
        }
    }
}